/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package IFSv2.Util;

/**
 *
 * @author Joel
 */

import java.util.HashMap;

public class utilBidirectionalMap<K, V> {
    
    private HashMap<K, V> forwardMap = new HashMap();
    private HashMap<V, K> backwardMap = new HashMap();

    public void put(K key, V value) {
        this.forwardMap.put(key, value);
        this.backwardMap.put(value, key);
    }

    public V getForward(K key) {
        return this.forwardMap.get(key);
    }

    public K getBackward(V value) {
        return this.backwardMap.get(value);
    }
    
    public void remove(K key){
        this.backwardMap.remove(this.forwardMap.get(key));
        this.forwardMap.remove(key);
    }
    
    public boolean containsKey(K key){
        return this.forwardMap.containsKey(key) && this.backwardMap.containsValue(key);
    }
    
    public void printKeyList(){
        System.out.print(forwardMap);
    }
}
